package com.mybatis.plus.join.config;


import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
import com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory;
import com.mybatis.plus.join.JoinSqlInjector;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * mybatis-plus配置
 *
 * @author by zhaojin
 * @since 2021/7/5 9:37
 */
@Configuration
public class MybatisPlusConfig {

    @Bean
    public DynamicResultMapInterceptor dynamicResultMapInterceptor() {
        return new DynamicResultMapInterceptor();
    }

    @Bean
    public JoinSqlInjector joinSqlInjector() {
        return new JoinSqlInjector();
    }


    /**
     * 开启返回map结果集的下划线转驼峰,便于map转对象
     */
    @Bean
    public ConfigurationCustomizer mybatisConfigurationCustomizer() {
        return configuration -> configuration.setObjectWrapperFactory(new MybatisMapWrapperFactory());
    }
}
